package com.tanhua.management.controller;

import com.tanhua.management.service.DashBoardService;
import com.tanhua.management.vo.DistributionVo;
import com.tanhua.management.vo.SummaryVo;
import com.tanhua.management.vo.UsersStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LY
 * @Description:
 * @Date: Created in 9:37 2021/1/17
 * @ModifiedBy:
 */

@RestController
@RequestMapping("dashboard")
public class DashBoardController {

    @Autowired
    private DashBoardService dashBoardService;

    /**
     * 概要统计信息
     *
     * @return
     */
    @GetMapping("summary")
    public ResponseEntity<SummaryVo> getSummary() {
        return dashBoardService.getSummary();
    }

    /**
     * 新增、活跃用户、次日留存率
     *
     * @param sd
     * @param ed
     * @param type
     * @return
     */
    @GetMapping("users")
    public ResponseEntity<UsersStatisticsVo> getUsers(@RequestParam(value = "sd") Long sd,
                                                      @RequestParam(value = "ed") Long ed,
                                                      @RequestParam(value = "type") Integer type) {
        return dashBoardService.getUsers(sd, ed, type);
    }

    /**
     * 注册用户分布，行业top、年龄、性别、地区
     *
     * @param sd
     * @param ed
     * @return
     */
    @GetMapping("distribution")
    public ResponseEntity<DistributionVo> getDistribution(@RequestParam(value = "sd") Long sd,
                                                          @RequestParam(value = "ed") Long ed) {
        return dashBoardService.getDistribution(sd, ed);
    }
}
